<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <link rel="stylesheet" href="style.css">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 引入 Bootstrap -->
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
  <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>


</head>
<body>
<div id="app">
<div class="container" >

  <div v-if="books.length>0">
    <table class="table table-striped text-center">
      <thead>
      <tr>
        <th>编号</th>
        <th>书籍名称</th>
        <th>出版日期</th>
        <th>价格</th>
        <th>购买数量</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>

      <tr v-for="(book,index) in books">
        <!--这里使用 index 作为编号 即使删除某项 编号也是连续的-->
        <td>{{index+1}}</td>
        <td>{{book.name}}</td>
        <td>{{book.date}}</td>
        <!--    价格显示 使用函数的方式-->
        <!--    <td>{{getFinalPrice(book.price)}}</td>-->
        <!--    使用过滤器的方式-->
        <td>{{book.price | showPrice }}</td>

        <td>
          <button @click="btn_reduce(book)">-</button>
          {{book.count}}
          <button @click="btn_increase(book)">+</button>
        </td>
        <td><button @click="btn_delete(book)">移除</button></td>
      </tr>

      <tr>
        <td>总价</td>
        <td>{{totalPrice3}}</td>
      </tr>

      </tbody>
    </table>
  </div>

  <div v-else>
    <h2>购物车为空</h2>
  </div>



</div>


</div>
<script src="../js/vue.js"></script>
<script src="main.js"></script>

</body>
</html>